import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.TextArea;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;


public class MyPanel extends JPanel implements ActionListener, ChangeListener {
	JColorChooser _tcc;
	TextArea _ta ;
	public MyPanel(TextArea ta){
		super();
		_ta =ta;
		this.setPreferredSize(new Dimension(500,this.getPreferredSize().height));
	 this.setLayout(new GridBagLayout());
	 GridBagConstraints gc = new GridBagConstraints();
	 
	 // set up color chooser 
	 _tcc = new JColorChooser();
	 
	 _tcc.getSelectionModel().addChangeListener(this);
	 
	 
	 
	 //grid layout
	 
	 gc.gridx = 0;
	 gc.gridy =0;
	 this.add(_tcc,gc);
	 
	 
	 
	}

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Override
	public void stateChanged(ChangeEvent arg0) {
		Color newColor = _tcc.getColor();
		_ta.setForeground(newColor);
		// TODO Auto-generated method stub
		
	}

	@Override
	// for button press
	public void actionPerformed(ActionEvent e) {
		// TODO Auto-generated method stub
		
	}

}
